package com.internetplus.webcore.service.impl;

import com.internetplus.webcore.service.PictureSave;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;


@Service
public class PictureSaveImpl implements PictureSave {

    @Override
   public String writeimg2local(MultipartFile img) throws IOException {

        String path = "D:\\test\\";

        String fileName = img.getOriginalFilename();

        File filePath = new File(path, fileName);

        if (!filePath.getParentFile().exists()) {

            filePath.getParentFile().mkdirs();
            System.out.println("创建目录"+filePath);
        }

        img.transferTo(filePath);

        return path+fileName;

    }

}
